package com.example.carefree_server.controller.c_departmentController;
import com.example.carefree_server.entity.Activity;
import com.example.carefree_server.entity.Pbactivity;
import com.example.carefree_server.entity.Result;
import com.example.carefree_server.service.s_departmentService.signInFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/signInForm")
public class signInFormController {
    @Autowired
    private signInFormService signInFormService;

    //（增）设计签到表，即需要什么样子的信息的签到表
    @PostMapping("/add")
    private Result addTweet(@RequestBody @Validated Pbactivity pb) {
        signInFormService.addtweet(pb);
        return Result.success();
    }

    //删除签到表
    @DeleteMapping("/delete")
    private Result deletetweet(Integer aid){
        signInFormService.deletetweet(aid);
        return Result.success();
    }

    //（改）更新所设置的签到表
    @PutMapping("/update")
    private Result updatetweet(@RequestBody @Validated Pbactivity pb){
        signInFormService.updatetweet(pb);
        return Result.success();
    }

    //（单个查询）查询签到表，即签到表显示的样子
    @GetMapping ("/select")
    private  Result selecttweet( Integer aid) {
        return Result.success(signInFormService.selecttweet(aid));
    }

    //（全部查询）查询列出所有的签到表
    @GetMapping("/all")
    private Result alltweet(){
        return Result.success(signInFormService.alltweet());
    }

    //查询部门自己的所设计过的全部签到表
    @GetMapping("/deselect")
    private Result detweet(@RequestParam String did){
        return  Result.success(signInFormService.detweet(did));
    }

}
